<!DOCTYPE html>
<html class="no-js">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <!-- Note to developers: Run the "grunt check" task to run these tests in the
        PhantomJS browser. (PhantomJS is based on webkit, so it should behave similar
        to safari or chrome.) To run in other browsers, run "grunt" (the default task)
        to compile crafty.js, then open this HTML file to run the tests. However,
        you may need to change browser security settings:
           * To run the tests in firefox: First you need to go to about:config in firefox, and
                 switch "security.fileuri.strict_origin_policy" to false. [This only changes the
                 security settings when firefox opens an HTML file saved on your computer; it does
                 not affect your security when you are browsing the internet.]
           * To run the tests in chrome: You need to pass a flag when opening chrome.
                 For example, in Linux, you would run this command in a Linux terminal:
                 chromium-browser /path/to/core.html --allow-file-access-from-files
    -->

    <!-- DEPENDENCIES -->
    <link rel="stylesheet" href="./lib/qunit.css" type="text/css" media="screen" />
    <script type="text/javascript" src="./lib/qunit.js"></script>
    <script type="text/javascript" src="./lib/mockTouchEvents.js"></script>
  </head>

  <body>
    <h1 id="qunit-header">Crafty.js Test Suite</h1>
    <h2 id="qunit-banner"></h2>
    <div id="qunit-testrunner-toolbar"></div>
    <h2 id="qunit-userAgent"></h2>
    <ol id="qunit-tests"></ol>
    <div id="qunit-fixture">test markup, will be hidden</div>

    <!-- CRAFTY.JS -->
    <script type="text/javascript" src="../../crafty.js"></script>

    <!-- DISABLE AUTOMATIC TEST START -->
    <script type="text/javascript">
        QUnit.config.autostart = false;
    </script>

    <!-- GET COMMON TEST FILES THAT RUN IN BROWSER AND NODE -->
    <script type="text/javascript" src="./index-common.js"></script>
    <!-- GET TEST FILES THAT ONLY RUN IN BROWSER -->
    <script type="text/javascript" src="./index.js"></script>

    <!-- LOAD TESTS AS SCRIPTS -->
    <!-- see https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement -->
    <script type="text/javascript">
        function loadScript (src, onload) {
            var script = document.createElement("script");
            script.type = "text\/javascript";
            script.onerror = function(error) {
                throw new URIError("The script " + error.target.src + " is not accessible!");
            };
            script.onload = onload;
            (document.body || document.getElementsByTagName("body")[0]).appendChild(script);
            script.src = src;
        }

        var totalFiles = window.COMMON_TEST_FILES.length + window.BROWSER_TEST_FILES.length;
        var loadedFiles = 0;
        /** START LOADED QUNIT TESTS ONCE ALL FILES LOADED **/
        var callback = function() {
            if (++loadedFiles === totalFiles) {
                QUnit.start();
            }
        };

        /** LOAD TEST FILES **/
        window.COMMON_TEST_FILES.concat(window.BROWSER_TEST_FILES).forEach(function (file) {
            loadScript(file, callback);
        });
    </script>
  </body>
</html>
